package com.goodcol.plugin.tool;

import com.intellij.notification.Notification;
import com.intellij.notification.NotificationGroup;
import com.intellij.notification.NotificationType;
import com.intellij.notification.Notifications;
import com.intellij.openapi.actionSystem.AnAction;

/**
 * Notification通知工具类
 *
 * @author Shanhy
 * @version 1.0.0
 * @date 2024-02-02 15:24:25
 */
public class NotificationUtils {

    /**
     * INFO_NOTIFICATION_GROUP
     */
    private static final NotificationGroup INFO_NOTIFICATION_GROUP = NotificationGroup.findRegisteredGroup("infoNotificationGroup");

    /**
     * NotificationUtils
     */
    private NotificationUtils() {
        // nothing
    }

    /**
     * showInfoNotification
     *
     * @param content content
     */
    public static void showInfoNotification(String content) {
        assert INFO_NOTIFICATION_GROUP != null;
        Notification notification = INFO_NOTIFICATION_GROUP.createNotification(content, NotificationType.INFORMATION);
        Notifications.Bus.notify(notification, ProjectUtils.getCurrProject());
    }

    /**
     * showInfoNotification
     *
     * @param title   title
     * @param content content
     */
    public static void showInfoNotification(String title, String content) {
        assert INFO_NOTIFICATION_GROUP != null;
        Notification notification = INFO_NOTIFICATION_GROUP.createNotification(title, content, NotificationType.INFORMATION);
        Notifications.Bus.notify(notification, ProjectUtils.getCurrProject());
    }

    /**
     * showInfoNotification
     *
     * @param title    title
     * @param content  content
     * @param anAction anAction
     */
    public static void showInfoNotification(String title, String content, AnAction anAction) {
        assert INFO_NOTIFICATION_GROUP != null;
        Notification notification = INFO_NOTIFICATION_GROUP.createNotification(title, content, NotificationType.INFORMATION);
        notification.addAction(anAction);
        Notifications.Bus.notify(notification, ProjectUtils.getCurrProject());
    }

}
